import { request } from "@umijs/max";

export async function getPostList(params: API.PageParams) {
    return request<API.Page<API.Post>>('/api/system/post', {
        params,
    });
}

export async function addPost(data: API.Post) {
    return request<API.Result<any>>('/api/system/post', {
        method: 'POST',
        data,
    });
}

export async function updatePost(data: API.Post) {
    return request<API.Result<any>>('/api/system/post', {
        method: 'PUT',
        data,
    });
}

export async function deletePost(id: number) {
    return request<API.Result<any>>(`/api/system/post/${id}`, {
        method: 'DELETE',
    });
}

export async function getPost(id: number) {
    return request<API.Result<API.Post>>(`/api/system/post/${id}`, {
        method: 'GET',
    });
}

export async function getPostTree() {
    return request<API.Result<API.Post[]>>('/api/system/post/tree', {
        method: 'GET',
    });
}

export async function getPostOptions() {
    return request<API.Result<API.Post[]>>('/api/system/post/options', {
        method: 'GET',
    });
}